refactor(math): use canonical integer conversions - #807
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b1cfcad10
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @model_validator(mode="after") | ||
| def require_nonnegative_parts(self) -> Self: | ||
| if any(int(v) < 0 for v in self.values): | ||
| if any(parse_canonical_integer(value) < 0 for value in self.values): |
There was a problem hiding this comment.
Bound multinomial parts before accepting large values
For a multinomial request containing the newly tested 5,001-digit value, this validator now succeeds, but its only consumer passes the parsed value to math.factorial in domains/combinatorics/operations.py:61-62; CPython immediately raises OverflowError once an argument exceeds sys.maxsize. Thus a request accepted by the capability contract still ends in an execution error. Add an explicit supported-magnitude/resource bound here rather than treating every canonical integer as computable.
AGENTS.md reference: AGENTS.md:L16-L17
Useful? React with 👍 / 👎.
|
|
||
| def _values(request: IntegerSequenceRequest) -> list[int]: | ||
| return [int(value) for value in request.values] | ||
| return [parse_canonical_integer(value) for value in request.values] |
There was a problem hiding this comment.
Bound sequence digits before parsing every operand
IntegerSequenceRequest limits only the item count, so this change makes previously guarded oversized operands reachable by every sequence operation. For example, 256 canonical powers of ten with 32,768 digits each fit within the default 10 MiB input limit, but prefix_products retains and formats 256 growing products totaling over one billion decimal digits, allowing one valid request to exhaust server CPU and memory. Enforce a total input/output digit budget before converting the sequence.
AGENTS.md reference: AGENTS.md:L16-L17
Useful? React with 👍 / 👎.
Fixes #756.
Replace direct Python decimal conversions at unbounded canonical-integer boundaries with the canonical parser and formatter. This covers contracts, arithmetic, combinatorics, matrix-lattice, polynomial, projective geometry, sequences, plugins, and shrinking.
Regression coverage exercises values beyond CPython's 4,300-digit conversion guard.
Validation:
make lint-full— passed